<template>
	<view class="om-page">
		<!-- #ifdef H5 -->
		<view :style="[{top:getCustomBar + 'px'}]">
			<slot></slot>
		</view>
		<!-- #endif -->
		<!-- #ifndef H5 -->
		<view>
			<slot></slot>
		</view>
		<!-- #endif -->
	</view>
</template>
<script>
	import { mapState } from 'pinia';
	import {useLoginUserStore} from '@/stores/login-user.js';
	const app = getApp();
	export default {
		provide() {
			return {
				page: this
			}
		},
		props:{
			title:{
				type:String,
				default(){
					return "O&M"
				}
			}
		},
		data() {
			return {
				show:false,
				isBack:true
			};
		},
		computed: {
			...mapState(useLoginUserStore, ['hasLogin'])
			,
			getCustomBar(){
				if(this.show){
					return this.CustomBar
				}else{
					return 0
				}
			}
		},
		created(){
			if(this.$page.path.indexOf("/pages/login") < 0 
			 && this.$page.path.indexOf("/pages/sso") < 0 
			 && this.$page.path.indexOf("/pages/public/filetable/filetable") < 0
			 && this.$page.path.indexOf("/pages/public/img-view/img-view") < 0
			 ){
				if(!this.hasLogin){
					uni.switchTab({
						url:"/pages/main/main/main"
					})
				}
			}
			// #ifdef MP-WEIXIN
			this.show = true
			let pages = getCurrentPages();
			let path = pages[pages.length-1].route
			if(path === "" 
			|| path === "pages/main/main/main" 
			|| path === "pages/user/user" 
			|| path === "pages/base/addr/phone/phone" 
			|| path === "pages/public/filetable/filetable" 
			|| ~path.indexOf("pages/sso")
			|| ~path.indexOf("pages/login")
			){
				this.isBack = false
			}else{
				if(!this.hasLogin){
					uni.switchTab({
						url:"/pages/main/main/main"
					})
				}
			}
			// #endif
		},
	}
</script>
